<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>ad</title>
    <link rel="stylesheet" type="text/css" href="../css/page/common.css" />
  <style>
      .demo-list div {
          border: 1px solid blue;
          margin-bottom: 20px;
          padding: 10px 20px;
          display: inline-block;
          margin-top: 100px;
      }
  </style>
</head>

<body>
    <div class="page" @vue:mounted="mounted">
        {{data.username}}
        <div class="demo-list">
               
                <div @click="adinitFun">init</div>
                <div @click="adsplashFun">Splash</div>
                <div @click="adgvFun">adGV</div>

                <div @click="openTest">显示开屏广告</div>
                <div @click="feedTest">信息流</div>
                <!-- <div @click="verticalTest">竖屏视频</div> -->
                <div @click="fullTest">全屏视频1</div>
                <div @click="interTest">插屏1</div>
                <div @click="patchTest">视频贴片</div>   
                <!-- 107050:视频无法播放 -->
                
        </div>
    </div>
</body>
<script src="../script/api.js"></script>
<script src="../script/common.js"></script>

<script type="module">
    import { createApp } from 'https://www.chenxiangle.com/app/web/script/pvue.js';
    const APP = () => {
        createApp({
            data: {
                bdad:null 
            },

            openTest(){
                core.ad.bd.init().then((zAd)=>{
                      core.log('test====')
                      setTimeout(()=>{
                            core.ad.bd.splash();
                        },1000)
                    })
            },
            // 信息流
            feedTest(){
                core.ad.bd.init().then((zAd)=>{
                      core.log('feedTest====')
                      setTimeout(()=>{
                            core.ad.bd.feed();
                        },1000)
                    })
            },
            // 全屏视频
            fullTest(){
                core.ad.bd.init().then((zAd)=>{
                      core.log('fullTest====')
                      setTimeout(()=>{
                            core.ad.bd.fullvideo();
                        },1000)
                    })
            },
            // 插屏
            interTest(){
                core.ad.bd.init().then((zAd)=>{
                      core.log('interTest====')
                      setTimeout(()=>{
                            core.ad.bd.inter();
                        },1000)
                    })
            },
            // 视频贴片
            patchTest(){
                core.ad.bd.init().then((zAd)=>{
                      core.log('patchTest====')
                      setTimeout(()=>{
                            core.ad.bd.patch();
                        },1000)
                    })
            },
            adinitFun(){
                var zyBaiduAd = api.require('zyBaiduAd');
                this.data.bdad = zyBaiduAd;
                var param = {
                    appId:api.systemType=='ios'?"fdd1c3c7":"fdd1c3c7",
                    appName:"辰乡乐",
                };
                // 初始化插件
                this.data.bdad.adInit(param,function(ret){
                    console.log("zyBaiduAd："+JSON.stringify(ret));
                    api.removeLaunchView();
                    api.toast({ msg:ret.result })
                });
            },
            adgvFun(){
                   var param = {
                        codeId:api.systemType=='ios'?"16089059":"16089059",//代码位
                        userId:"",//用户id
                        extraData:"",//自定义参数
                    };
                    api.showProgress({});
                    let thatad6 =  this.data.bdad;
                    // 加载激励视频广告
                    this.data.bdad.adLoadRewardVideo(param,function(ret){
                        console.log("zyBaiduAd："+JSON.stringify(ret));
                        if(ret.status){
                            if(ret.result == "缓存成功"){
                                api.hideProgress();
                                //缓存成功后可以展示广告
                                //moduleClick('adShowRewardVideo');
                                //api.setFullScreen({fullScreen: true,animation:"slide"});

                                // 展示激励视频
                                thatad6.adShowRewardVideo(function(ret){
                                            console.log("zyBaiduAd："+JSON.stringify(ret));
                                            if(!ret.status){
                                                api.toast({ msg:ret.result })
                                            }
                                        });
                                  }
                            if(ret.result == "关闭"){
                                // 全屏展示
                                api.setFullScreen({fullScreen: false,animation:"slide"});
                            }
                        }else{
                            api.hideProgress();
                            api.toast({ msg:ret.result })
                        }
                    });
            },
            adsplashFun(){
                var param = {
                    codeId:api.systemType=='ios'?"16089061":"16089061",//默认测试代码位
                    rect:{//开屏位置 默认0即为全屏 也可自定义
                            x:0,
                            y:0,
                            w:0,
                            h:0
                        },
                        fixedOn:"",
                        fixed:true
                    };
                    core.log(this.data.bdad)
                    // 展示开屏广告
                    this.data.bdad.adShowSplash(param,function(ret){
                        console.log("zyBaiduAd："+JSON.stringify(ret));
                        if(ret.status){
                            if(ret.result == "展示"){
                                api.setFullScreen({fullScreen: true,animation:"slide"});
                            }
                            if(ret.result == "关闭"){
                                api.setFullScreen({fullScreen: false,animation:"slide"});
                            }
                        }else{
                            api.toast({ msg:ret.result })
                        }
                    });
            },

            mounted() {
                console.log("mounted");
                window.app = this;
                


            }
        }).mount()
    }

    window.apiready = () => {
        console.log("ready");
        APP();
    }

    window.apiready();
</script>


</html>